<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
          <%
	String path = request.getContextPath();
	//request.getScheme()：请求协议http，https
	//request.getServerName()：服务器名字：也就是ip地址
	//request.getServerPort()：端口号
	//path：项目路径
	//bashPath=http://localhost/8888/
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加项目分类</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
    <link rel="stylesheet" href="css/dashboard.css" />
</head>
<body>
<!--上部导航栏start-->
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">众筹管理平台</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">

            <ul class="nav navbar-nav navbar-right">
                <li><a href="index.html">首页</a></li>
                <li><a href="#">欢迎, 张三</a></li>
                <li><a href="#" title="修改个人资料和密码的页面">设置</a></li>
                <li><a href="#" title="退出登录">退出</a></li>
            </ul>
        </div>
    </div>
</nav>
<!--上部导航栏end-->
<div class="container-fluid">
    <div class="row">
        <!--左侧导航栏start-->
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li ><a href="hindex.do">首页</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="admin/query.do">所有项目</a></li>
                <li><a href="Review/querytype.do">项目审核</a></li>
                <li><a href="#">项目跟踪</a></li>
                <li><a href="comment/queryc.do">项目评论</a></li>
                <li><a href="type/querytype.do">项目分类</a></li>
                <li><a href="#">项目推荐</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="">注册用户</a></li>
                <li><a href="mon/query.do">用户资金</a></li>
                <li><a href="#">用户日志</a></li>
                <li><a href="audit/query.do">实名审核</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="">新闻管理</a></li>
                <li><a href="ques/question.do">问题管理</a></li>
                <li class="active"><a href="adminPower.do">管理用户</a></li>
                <li><a href="">管理日志</a></li>
            </ul>
        </div>
        <!--左侧导航栏end-->
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">管理用户</h1>

            <div class="panel panel-default">
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        管理用户
                    </div>
                </div>
 <div class="panel-body">
			<form class="form-inline"  method="post" action="adminPower.do" >
			  <div class="form-group">
			    <input type="text" class="form-control" id="adminName" name="adminName" placeholder="管理员账户">
			  </div>

			  <div class="form-group">
			   <select class=form-control name="heihei"> 
			   	<option value=null>管理员权限</option>
			   	<option value=1>超管</option>
			   	<option value=2>普通管理员</option>
			   	<option value=0>老板</option>
			   </select>
			  </div>
			  &nbsp;&nbsp;
			  <button type="submit" class="btn btn-default btn-primary">查询</button>
			</form>
    </div>
            </div>
			<div class="panel panel-default">
  <div class="panel-heading">
    <div class="panel-title">
    	所有管理员列表
    </div>
  </div>
  <div class="panel-body">
          <div class="table-responsive ">
            <table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th><center>序号</center></th>
                  <th><center>管理员账户</center></th>
                  <th><center>管理员密码</center></th>
                  <th><center>管理员权限</center></th>
                 <th colspan="2"><center> 操作</center></th>
                </tr>
              </thead>
             <tbody>
			  <c:forEach items="${admins}" var="admin">  
                <tr align="center">
                  <td>${admin.adminId}</td>
                  <td>${admin.adminName}</td>
                  <td>${admin.adminPassword}</td>
                  <td>
                  <c:if test="${admin.adminPowerId==0}">老板</c:if> 
                  <c:if test="${admin.adminPowerId==1}">超管</c:if> 
                  <c:if test="${admin.adminPowerId==2}">普通管理员</c:if> 
                  </td>
                  <td>
                  	<a href="JavaScript:void(0)"  data-toggle="modal" data-target="#myModal" onclick="add1('${admin.adminId}','${admin.adminName}','${admin.adminPassword}','${admin.adminPowerId}')">修改</a>
                  </td>
                  <td>
                  	<a href="deladmin.do?adminId=${admin.adminId}">删除</a>
                  </td>
                  
                </tr>
            </c:forEach>
              </tbody>
            </table>
          </div>

  	             <nav aria-label="Page navigation" class="text-right">
				  <ul class="pagination">
				    <li class="disabled">
				        <span aria-hidden="true">&laquo;</span>
				    </li>
				    <li><a href="adminPower.do?page=1">首页</a></li>
				      <c:if test="${page.pageNum>1}" >
				    <li><a href="adminPower.do?page=${page.prePage}">上一页</a></li>
				      </c:if>
				       <c:if test="${page.pageNum<page.lastPage}" >
				    <li><a href="adminPower.do?page=${page.nextPage}">下一页</a></li>
				      </c:if>
				     <li><a href="adminPower.do?page=${page.lastPage}">尾页</a></li>
				    <li>
				    <li class="disabled">
				        <span aria-hidden="true">&raquo;</span>
				    </li>
				  </ul>
				</nav>   	
  </div>
 

</div>
        </div>
    </div>
</div>

<c:forEach items="${admins}" var="admin">  
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">修改管理员信息</h4>
            </div>
            <div class="modal-body">
            	序号：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input readonly="readonly" class="form-inline" type="text" name="adminId" id="adminId" /><br><br>
            	管理员账户：<input class="form-inline" type="text" id="adminName1" name="adminName" /><br><br>
            	管理员密码：<input class="form-inline" type="text" id="adminPassword" name="adminPassword" /><br><br>
            	管理员权限：<select class="form-inline" id="adminPowerId">
			   				<option value=1>超管</option>
			   				<option value=2>普通管理员</option>
			   				<option value=0>老板</option>
            	</select>
           
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" id="btnn">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</c:forEach>
</body>
		<script type="text/javascript" src="admin/js/jquery1.12.4.min.js" ></script>
		<script type="text/javascript" src="admin/js/bootstrap.js" ></script>
		<script type="text/javascript" src="admin/js/countUp.js" ></script>
		<script type="text/javascript" src="js/toastr.js"></script>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
	
	function add1(a,b,c,d){
		var e ;
		if (d==0) {
			e = "老板";
		}else if (d==1) {
			e = "超管";
		}else if (d==2) {
			e = "普通管理员";
		}
		$("#adminId").attr("value",a);
		$("#adminName1").attr("value",b);
		$("#adminPassword").attr("value",c);
		$("#adminPowerId").attr("value",e);
	}
	$("#btnn").click(function(){
		var adminId = $("#adminId").val();
		var adminName1 = $("#adminName1").val();
		var adminPassword = $("#adminPassword").val();
		var aa = $("#adminPowerId").val();
		$.ajax({
			url:"updateAdmin.do",
			type:"post",
			data:{"adminId":adminId,"adminName":adminName1,"adminPassword":adminPassword,"adminPowerId":aa},
			success:function(data){
				if (data=="0") {
					toastr.success("修改成功");
					setTimeout(function(){window.location.href="adminPower.do"},600);
				}else if (data=="1") {
					toastr.error("修改失败");
				}
			},
			error:function(){
				toastr.error("网络繁忙，稍后再试");
			},
		})
	})
</script>
	
</html>